/**
 * related to list.ui
 * 
 * @Author : chenglm
 * @Timestamp : 2016-07-15
 */
var page = sm("do_Page");
var app = sm("do_App");
var hashdata = mm("do_HashData");
var rootview = ui("$");
var nf = sm("do_Notification");
var common = require("common");
var pubUrl = require("url/pub");
var qqHttp = require("helper/http");
var listview = ui("listview");
var listdata = mm("do_ListData");
listview.bindItems(listdata);
var noData = [{"template":1,"labelContent":"还没有评论哦"}];
var data = page.getData();

//andriod返回键
page.on("back", function() {
    app.closePage();
});

/* 头部 */
var headerAout = ui("do_ALayout_header");
var addheader = headerAout.add("header", "source://view/reuse/header.ui", 0, 0);
var header = ui("header");
//左上角-返回
var headerLeft = ui(addheader+".headerLeft");
headerLeft.on("touch", function() {
    app.closePage()
});
var labelTitle = ui(addheader+".labelTitle");
labelTitle.text = data.name;
//刷新数据
function refreshAllData(){
	var productId = data.productId;
	qqHttp.post(pubUrl.url.feedback.page, {type:1,productId:productId}, function(data) {
		listview.rebound();
		listdata.removeAll();
		if (data.page.content.length) {
			img_domain = data.page.content[0].fileDomain;
			listdata.addData(data.page.content);
		}else{
			listdata.addData(noData);
		}
		listview.bindItems(listdata);
		listview.refreshItems();
	})
}
refreshAllData();
//下拉列表，刷新数据
listview.on("pull", function(data) {
	if (data.state == 2) {
		refreshAllData();
		listview.rebound();
	}
});

//上拉列表，翻页数据
listview.on("push", function(data) {
	if (data.state == 2) {
		listview.rebound();
	}
});